package com.it.share;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;

import javax.sql.DataSource;

@ComponentScan(basePackages = "com.it.share")
@Configuration
public class AppConfig {

    @Bean
    public DataSource b0() {
        DataSource dataSource = new SingleConnectionDataSource(
                "jdbc:h2:mem:test1",
                "root",
                "root",
                true
        );
        return dataSource;
    }

    @Bean
    public JdbcTemplate b1(DataSource dataSource) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        jdbcTemplate.setDatabaseProductName("h2");
        return jdbcTemplate;
    }

}
